Skip to content

BUG: error when unstacking in DataFrameGroupby.apply #52446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

topper-123
Copy link
Contributor

@@ -295,6 +295,7 @@ Groupby/resample/rolling
or :class:`PeriodIndex`, and the ``groupby`` method was given a function as its first argument,
the function operated on the whole index rather than each element of the index. (:issue:`51979`)
- Bug in :meth:`GroupBy.var` failing to raise ``TypeError`` when called with datetime64 or :class:`PeriodDtype` values (:issue:`52128`)
- Bug in :meth:`DataFrameGroupBy.apply` when the supplied callable unstacked the grouped :class:`DataFrame` and returned a :class:`Series`, an attempt was made to set a list as the name of the result ``Series``, causing an error to be raised (:issue:`52444`)
Copy link
Member

@rhshadrach rhshadrach Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this bug occurs a bit more generally - anytime the input DataFrame is subset as a DataFrame after groupby ([['a']] and not ['a']) and the UDF returns Series that aren't all indexed the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve reformulated.

@rhshadrach rhshadrach added Bug Groupby Apply Apply, Aggregate, Transform, Map labels Apr 5, 2023
@rhshadrach rhshadrach added this to the 2.1 milestone Apr 5, 2023
@mroeschke mroeschke merged commit 79e3ee6 into pandas-dev:main Apr 6, 2023
@mroeschke
Copy link
Member

Thanks @topper-123

@topper-123 topper-123 deleted the DataframeGroupby_apply_unstacking branch April 6, 2023 16:35
topper-123 added a commit to topper-123/pandas that referenced this pull request Apr 6, 2023
* BUG: error when unstacking in DataFrameGroupby.apply

* fix pre-commit

* adjust whatsnew for comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform, Map Bug Groupby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: error when unstacking in DataFrame.groupby.apply
3 participants